package com.css.fxfzcpxx.modules.houseSeismicEvaluation.repository.impl;

import com.css.fxfzcpxx.modules.houseSeismicEvaluation.entity.HouSeiEvaluation;
import com.css.fxfzcpxx.modules.houseSeismicEvaluation.repository.HouSeiEvaluationRepository;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class HouSeiEvaluationRepositoryImpl implements HouSeiEvaluationRepository {

    @Resource
    JdbcTemplate jdbcTemplate;

    @Resource
    NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    @Override
    public void save(HouSeiEvaluation houSeiEvaluation) {
        String sql = "insert into cpxx_house_seismic_evaluation(id,province,city,country,storey_number,structure_type,defense_situation,purpose,age," +
                "earthquake_intensity,house_destruction_situation,house_performance_evaluation,opinion,create_user,create_time,purpose1,structure_type1) " +
                "values(:id, :province, :city, :country, :storeyNumber, :structureType, :defenseSituation, :purpose, :age, " +
                ":earthquakeIntensity, :houseDestructionSituation, :housePerformanceEvaluation, :opinion, :createUser, :createTime, :purpose1 , :structureType1)";
        SqlParameterSource source = new BeanPropertySqlParameterSource(houSeiEvaluation);
        namedParameterJdbcTemplate.update(sql, source);
    }
}
